package com.bit.cfdi.web.services;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bit.cfdi.web.domain.Usuario;
import com.bit.cfdi.web.utils.EncryptionUtils;

@Service
public class LoginService {

	@Autowired UsuarioService usuarioService;
	@Autowired EncryptionUtils encryptionUtils;
	
	public Usuario performLogin(final String email, final String password) {
		if(email == null || email.trim().isEmpty() || 
				password == null || password.trim().isEmpty()) {
			return null;
		}
		String passwordMD5 = encryptionUtils.stringEncryption(password);
		return usuarioService.getByEmailAndPassword(email, passwordMD5);
	}
}
